package top.zy.service.zymallgoodsservice.brand.controller;

import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import top.zy.common.zymallcommon.vo.PageResult;
import top.zy.service.zymallgoodsinterface.dto.BrandPageParam;
import top.zy.service.zymallgoodsinterface.entity.Brand;
import top.zy.service.zymallgoodsservice.brand.service.BrandService;

import java.util.List;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 10:34 2019/6/20
 */
@RestController
@RequestMapping("brand")
public class BrandController {
    @Autowired
    @Qualifier("brandServiceImpl")
    private BrandService brandService;

    /**
     * 分页查询品牌
     * @param brandPageParam
     * @return
     */
    @GetMapping("/page")
    public PageResult<Brand> queryBrandPage(BrandPageParam brandPageParam){
       return brandService.queryBrandPage(brandPageParam);
    }

    /***
     *新增品牌信息
     * @param brand
     * @param cids
     */
    @PostMapping("/add")
    public void saveBrand(Brand brand,@RequestParam("cids") List<Long> cids){
     brandService.saveBrand(brand,cids);
    }

    /***
     * 根据分了id查询品牌
     * @param id
     * @return
     */
    @GetMapping("/cid/{id}")
    public List<Brand> queryBrandListByCategoryId(@PathVariable("id") Long id){
     List<Brand> brandList= brandService.queryBrandListByCategoryId(id);
     return brandList;
    }

    /***
     * 根据品牌id查询品牌
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Brand queryBrandById(@PathVariable("id")Long id){
     return brandService.queryBrandById(id);
      }


    @GetMapping("list")
    List<Brand> queryBrandByIds(@RequestParam("ids")List<Long> ids){
        return brandService.queryBrandByIds(ids);
    }
}
